home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2c.lha / p4-1.2c / messages_f / temp.f < prev   
Text File  |  1993-05-24  |  3KB  |  140 lines

  1.       program systest
  2.  
  3.       include 'p4f.h'
  4.  
  5.       call p4init()
  6.  
  7.       call p4crpg()
  8.       if (p4myid() .eq. 0) then
  9.       call fmaster()
  10.       else
  11.       call fslave()
  12.       endif
  13.       call p4cleanup()
  14.       print *,'mainline exiting normally'
  15.       end
  16.  
  17.  
  18.       subroutine fmaster()
  19.  
  20.       include 'p4f.h'
  21.  
  22.       integer*4 i,toid,slaves,type,from,retcde,recvlen,buflen
  23.       character*40 buffer
  24.       integer*4 TAGCNT, TAGDAT, TAGEND, ALOG_TRUNCATE, SENDING
  25.       parameter (TAGCNT = 10)
  26.       parameter (TAGDAT = 20)
  27.       parameter (TAGEND = 30)
  28.       parameter (ALOG_TRUNCATE = 0)
  29.       parameter (SENDING = 99)
  30.  
  31.       print 11,'Entering fmaster'
  32. 11    format(a)
  33.  
  34.       call alogfenable()
  35.       call alogfmaster(p4myid(),ALOG_TRUNCATE)
  36.       call alogfdefine(SENDING,"Sending","")
  37.  
  38.       slaves = p4ntotids() - 1
  39.       length = 0
  40.       buflen = 40
  41.  
  42.       do 10 i = 1,slaves
  43.      call alogflog(p4myid(),SENDING,TAGCNT,"")
  44.          call p4sendr(TAGCNT,i,buffer,length,retcde)
  45. 10    continue
  46.  
  47. 20    print *,'Enter a string: '
  48.       read (*,99,end=50) buffer
  49. 99    format(a40)
  50.  
  51.       do 30 length=40,1,-1
  52.          if(buffer(length:length) .ne. ' ') goto 40
  53. 30    continue
  54.       length = 0
  55. 40    continue
  56.  
  57.       call alogflog(p4myid(),SENDING,TAGDAT,"")
  58.       toid = 1
  59.       call p4send(TAGDAT,toid,buffer,length,retcde)
  60.       buffer = ' '
  61.       type = TAGDAT
  62.       from = -1
  63.       call p4recv(type,from,buffer,buflen,recvlen,retcde)
  64.  
  65.       print *,'MASTER receives from=',from,' buffer=',buffer
  66.       length = 0
  67.       goto 20
  68. 50    continue
  69.  
  70.       do 60 i = 1,slaves
  71.      call alogflog(p4myid(),SENDING,TAGEND,"")
  72.          call p4sendr(TAGEND,i,buffer,buflen,retcde)
  73. 60    continue
  74.  
  75.       call alogfoutput()
  76.       print *,'Master exiting normally'
  77.       end
  78.  
  79.  
  80.       subroutine fslave()
  81.  
  82.       include 'p4f.h'
  83.  
  84.       character*40 buffer
  85.       integer*4 type, from, next, done, procid, length, buflen
  86.       integer*4 numsl, retcde, recvlen
  87.       integer*4 TAGCNT, TAGDAT, TAGEND, ALOG_TRUNCATE, SENDING
  88.       parameter (TAGCNT = 10)
  89.       parameter (TAGDAT = 20)
  90.       parameter (TAGEND = 30)
  91.       parameter (ALOG_TRUNCATE = 0)
  92.       parameter (SENDING = 99)
  93.  
  94.       numsl = p4ntotids() - 1
  95.       procid = p4myid()
  96.       buflen = 40
  97.  
  98. C     print 200,'slave ',procid,' has started'
  99. C200  format(a,i2,a)
  100. C     call p4flush
  101.  
  102.       if (procid .eq. numsl) then
  103.          next = 0
  104.       else
  105.          next = procid + 1
  106.       endif
  107.  
  108.       call alogfsetup(p4myid(),ALOG_TRUNCATE)
  109.  
  110. C     print 201,'slave ',procid,' next = ',next
  111. C201  format(a,i2,a,i2)
  112. C     call p4flush
  113.  
  114.       length = 40
  115.       from = -1
  116.       type = TAGCNT
  117.       call p4recv(type,from,buffer,length,recvlen,retcde)
  118.       done = 0
  119.  
  120. 50    if (done .ne. 0) goto 100
  121.  
  122.          buffer = ' '
  123.          length = 40
  124.          from = -1
  125.          type = -1
  126.          call p4recv(type,from,buffer,length,recvlen,retcde)
  127.          if (type .eq. TAGEND) then
  128.             done = 1
  129.          else
  130.         call alogflog(p4myid(),SENDING,TAGDAT,"")
  131.             call p4send(TAGDAT,next,buffer,recvlen,retcde)
  132.          endif
  133.          goto 50
  134.  
  135. 100   continue
  136.  
  137.       call alogfoutput()
  138.  
  139.       end
  140.